<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class RDoc::TomDoc - rdoc: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
<div id="sections-section" class="nav-section">
  <h3>Sections</h3>

  <ul class="link-list" role="directory">
      <li><a href="#5Buntitled-5D"></a></li>
      <li><a href="#Public">Public</a></li>
      <li><a href="#Internal">Internal</a></li>
  </ul>
</div>

        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Markup/Parser.html">RDoc::Markup::Parser</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-parse">::parse</a>
    <li ><a href="#method-c-signature">::signature</a>
    <li class="calls-super" ><a href="#method-i-build_heading">#build_heading</a>
    <li ><a href="#method-i-build_paragraph">#build_paragraph</a>
    <li class="calls-super" ><a href="#method-i-build_verbatim">#build_verbatim</a>
    <li ><a href="#method-i-tokenize">#tokenize</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-RDoc::TomDoc">
    <h1 id="class-RDoc::TomDoc" class="class">
      class RDoc::TomDoc
    </h1>

    <section class="description">
    
<p>A parser for <a href="TomDoc.html"><code>TomDoc</code></a> based on <a href="TomDoc.html"><code>TomDoc</code></a> 1.0.0-rc1 (02adef9b5a)</p>

<p>The <a href="TomDoc.html"><code>TomDoc</code></a> specification can be found at:</p>

<p><a href="http://tomdoc.org">tomdoc.org</a></p>

<p>The latest version of the <a href="TomDoc.html"><code>TomDoc</code></a> specification can be found at:</p>

<p><a href="https://github.com/mojombo/tomdoc/blob/master/tomdoc.md">github.com/mojombo/tomdoc/blob/master/tomdoc.md</a></p>

<p>To choose <a href="TomDoc.html"><code>TomDoc</code></a> as your only default format see <a href="Options.html#class-RDoc::Options-label-Saved+Options">Saved Options at <code>RDoc::Options</code></a> for instructions on setting up a <code>.rdoc_options</code> file to store your project default.</p>

<p>There are a few differences between this parser and the specification.  A best-effort was made to follow the specification as closely as possible but some choices to deviate were made.</p>

<p>A future version of <a href="../RDoc.html"><code>RDoc</code></a> will warn when a MUST or MUST NOT is violated and may warn when a SHOULD or SHOULD NOT is violated.  <a href="../RDoc.html"><code>RDoc</code></a> will always try to emit documentation even if given invalid <a href="TomDoc.html"><code>TomDoc</code></a>.</p>

<p>Here are some implementation choices this parser currently makes:</p>

<p>This parser allows rdoc-style inline markup but you should not depended on it.</p>

<p>This parser allows a space between the comment and the method body.</p>

<p>This parser does not require the default value to be described for an optional argument.</p>

<p>This parser does not examine the order of sections.  An Examples section may precede the Arguments section.</p>

<p>This class is documented in <a href="TomDoc.html"><code>TomDoc</code></a> format.  Since this is a subclass of the <a href="../RDoc.html"><code>RDoc</code></a> markup parser there isn’t much to see here, unfortunately.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





              </section>
      <section id="Public" class="documentation-section">
      <header class="documentation-section-title">
      <h2>
        Public
      </h2>
      <span class="section-click-top">
        <a href="#top">&uarr; top</a>
      </span>
      </header>





                <section id="public-class-Public-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="TomDoc.html"><code>TomDoc</code></a> parser.  See also <a href="Markup.html#method-c-parse"><code>RDoc::Markup::parse</code></a></p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="Markup/Parser.html#method-c-new"><code>RDoc::Markup::Parser::new</code></a>
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rdoc/tom_doc.rb, line 130</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
  <span class="ruby-keyword">super</span>

  <span class="ruby-ivar">@section</span>      = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@seen_returns</span> = <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse</span><span
                                class="method-args">(text)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses <a href="TomDoc.html"><code>TomDoc</code></a> from text</p>
<dl class="rdoc-list note-list"><dt>text
<dd>
<p>A String containing TomDoc-format text.</p>
</dd></dl>

<h3 id="method-c-parse-label-Examples">Examples<span><a href="#method-c-parse-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h3>

<pre class="ruby"><span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">TomDoc</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">&lt;&lt;-TOMDOC</span>
<span class="ruby-value">This method does some things

Returns nothing.
</span><span class="ruby-identifier">TOMDOC</span>
<span class="ruby-comment"># =&gt; #&lt;RDoc::Markup::Document:0xXXX @parts=[...], @file=nil&gt;</span>
</pre>

<h3 id="method-c-parse-label-Returns">Returns<span><a href="#method-c-parse-label-Returns">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Returns an <a href="Markup/Document.html"><code>RDoc::Markup::Document</code></a> representing the <a href="TomDoc.html"><code>TomDoc</code></a> format.</p>

                              <div class="method-source-code" id="parse-source">
            <pre><span class="ruby-comment"># File rdoc/tom_doc.rb, line 84</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse</span> <span class="ruby-identifier">text</span>
  <span class="ruby-identifier">parser</span> = <span class="ruby-identifier">new</span>

  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">tokenize</span> <span class="ruby-identifier">text</span>
  <span class="ruby-identifier">doc</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">doc</span>
  <span class="ruby-identifier">doc</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
      <section id="Internal" class="documentation-section">
      <header class="documentation-section-title">
      <h2>
        Internal
      </h2>
      <span class="section-click-top">
        <a href="#top">&uarr; top</a>
      </span>
      </header>



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-tokens" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">tokens</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Token accessor</p>
              </div>
            </div>
            </section>


                <section id="public-class-Internal-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-signature" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">signature</span><span
                                class="method-args">(comment)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Extracts the Signature section’s method signature</p>
<dl class="rdoc-list note-list"><dt>comment
<dd>
<p>An <a href="Comment.html"><code>RDoc::Comment</code></a> that will be parsed and have the signature extracted</p>
</dd></dl>

<h3 id="method-c-signature-label-Returns">Returns<span><a href="#method-c-signature-label-Returns">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Returns a String containing the signature and nil if not</p>

                              <div class="method-source-code" id="signature-source">
            <pre><span class="ruby-comment"># File rdoc/tom_doc.rb, line 100</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">signature</span> <span class="ruby-identifier">comment</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">comment</span>.<span class="ruby-identifier">tomdoc?</span>

  <span class="ruby-identifier">document</span> = <span class="ruby-identifier">comment</span>.<span class="ruby-identifier">parse</span>

  <span class="ruby-identifier">signature</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">found_heading</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-identifier">found_signature</span> = <span class="ruby-keyword">false</span>

  <span class="ruby-identifier">document</span>.<span class="ruby-identifier">parts</span>.<span class="ruby-identifier">delete_if</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">found_signature</span>

    <span class="ruby-identifier">found_heading</span> <span class="ruby-operator">||=</span>
      <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Heading</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">part</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">text</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;Signature&#39;</span>

    <span class="ruby-keyword">next</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">found_heading</span>

    <span class="ruby-keyword">next</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">BlankLine</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">part</span>

    <span class="ruby-keyword">if</span> <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Verbatim</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">part</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">signature</span> = <span class="ruby-identifier">part</span>
      <span class="ruby-identifier">found_signature</span> = <span class="ruby-keyword">true</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">signature</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">signature</span>.<span class="ruby-identifier">text</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-Internal-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-build_heading" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_heading</span><span
                                class="method-args">(level)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a heading from the token stream</p>
<dl class="rdoc-list note-list"><dt>level
<dd>
<p>The level of heading to create</p>
</dd></dl>

<h3 id="method-i-build_heading-label-Returns">Returns<span><a href="#method-i-build_heading-label-Returns">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Returns an RDoc::Markup::Heading</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="Markup/Parser.html#method-i-build_heading"><code>RDoc::Markup::Parser#build_heading</code></a>
                              </div>

                              <div class="method-source-code" id="build_heading-source">
            <pre><span class="ruby-comment"># File rdoc/tom_doc.rb, line 143</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_heading</span> <span class="ruby-identifier">level</span>
  <span class="ruby-identifier">heading</span> = <span class="ruby-keyword">super</span>

  <span class="ruby-ivar">@section</span> = <span class="ruby-identifier">heading</span>.<span class="ruby-identifier">text</span>

  <span class="ruby-identifier">heading</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_paragraph" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_paragraph</span><span
                                class="method-args">(margin)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a paragraph from the token stream</p>
<dl class="rdoc-list note-list"><dt>margin
<dd>
<p>Unused</p>
</dd></dl>

<h3 id="method-i-build_paragraph-label-Returns">Returns<span><a href="#method-i-build_paragraph-label-Returns">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Returns an <a href="Markup/Paragraph.html"><code>RDoc::Markup::Paragraph</code></a>.</p>

                              <div class="method-source-code" id="build_paragraph-source">
            <pre><span class="ruby-comment"># File rdoc/tom_doc.rb, line 173</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_paragraph</span> <span class="ruby-identifier">margin</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:paragraph_start</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-identifier">paragraph</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Paragraph</span>.<span class="ruby-identifier">new</span>

  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>, = <span class="ruby-identifier">get</span>

    <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:TEXT</span> <span class="ruby-keyword">then</span>
      <span class="ruby-ivar">@section</span> = <span class="ruby-string">&#39;Returns&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\A(Returns|Raises)/</span>

      <span class="ruby-identifier">paragraph</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:NEWLINE</span> <span class="ruby-keyword">then</span>
      <span class="ruby-keyword">if</span> <span class="ruby-value">:TEXT</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">peek_token</span>[<span class="ruby-value">0</span>] <span class="ruby-keyword">then</span>
        <span class="ruby-comment"># Lines beginning with &#39;Raises&#39; in the Returns section should not be</span>
        <span class="ruby-comment"># treated as multiline text</span>
        <span class="ruby-keyword">if</span> <span class="ruby-string">&#39;Returns&#39;</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@section</span> <span class="ruby-keyword">and</span>
          <span class="ruby-identifier">peek_token</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;Raises&#39;</span>) <span class="ruby-keyword">then</span>
          <span class="ruby-keyword">break</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">paragraph</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-keyword">break</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">p</span> <span class="ruby-value">:paragraph_end</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-identifier">paragraph</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_verbatim" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_verbatim</span><span
                                class="method-args">(margin)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a verbatim from the token stream.  A verbatim in the Examples section will be marked as in Ruby format.</p>
<dl class="rdoc-list note-list"><dt>margin
<dd>
<p>The indentation from the margin for lines that belong to this verbatim section.</p>
</dd></dl>

<h3 id="method-i-build_verbatim-label-Returns">Returns<span><a href="#method-i-build_verbatim-label-Returns">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Returns an <a href="Markup/Verbatim.html"><code>RDoc::Markup::Verbatim</code></a></p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="Markup/Parser.html#method-i-build_verbatim"><code>RDoc::Markup::Parser#build_verbatim</code></a>
                              </div>

                              <div class="method-source-code" id="build_verbatim-source">
            <pre><span class="ruby-comment"># File rdoc/tom_doc.rb, line 159</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_verbatim</span> <span class="ruby-identifier">margin</span>
  <span class="ruby-identifier">verbatim</span> = <span class="ruby-keyword">super</span>

  <span class="ruby-identifier">verbatim</span>.<span class="ruby-identifier">format</span> = <span class="ruby-value">:ruby</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@section</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;Examples&#39;</span>

  <span class="ruby-identifier">verbatim</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tokenize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">tokenize</span><span
                                class="method-args">(text)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Turns text into an Array of tokens</p>
<dl class="rdoc-list note-list"><dt>text
<dd>
<p>A String containing TomDoc-format text.</p>
</dd></dl>

<h3 id="method-i-tokenize-label-Returns">Returns<span><a href="#method-i-tokenize-label-Returns">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Returns self.</p>

                              <div class="method-source-code" id="tokenize-source">
            <pre><span class="ruby-comment"># File rdoc/tom_doc.rb, line 231</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tokenize</span> <span class="ruby-identifier">text</span>
  <span class="ruby-identifier">text</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/\A(Public|Internal|Deprecated):\s+/</span>, <span class="ruby-string">&#39;&#39;</span>)

  <span class="ruby-identifier">setup_scanner</span> <span class="ruby-identifier">text</span>

  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">eos?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">pos</span> = <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">pos</span>

    <span class="ruby-comment"># leading spaces will be reflected by the column of the next token</span>
    <span class="ruby-comment"># the only thing we loose are trailing spaces at the end of the file</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/ +/</span>)

    <span class="ruby-ivar">@tokens</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">case</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/\r?\n/</span>) <span class="ruby-keyword">then</span>
                 <span class="ruby-identifier">token</span> = [<span class="ruby-value">:NEWLINE</span>, <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">matched</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
                 <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">newline!</span>
                 <span class="ruby-identifier">token</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/(Examples|Signature)$/</span>) <span class="ruby-keyword">then</span>
                 <span class="ruby-ivar">@tokens</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-value">:HEADER</span>, <span class="ruby-value">3</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]

                 [<span class="ruby-value">:TEXT</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/([:\w][\w\[\]]*)[ ]+- /</span>) <span class="ruby-keyword">then</span>
                 [<span class="ruby-value">:NOTE</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-keyword">else</span>
                 <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/.*/</span>)
                 [<span class="ruby-value">:TEXT</span>, <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">matched</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/\r$/</span>, <span class="ruby-string">&#39;&#39;</span>), <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

